From 56be40fbef61fd32672209d38a5e874fea603e82 Mon Sep 17 00:00:00 2001 From: Daniel Sabo Date: Sat, 11 Jan 2014 18:44:32 -0800 Subject: [PATCH] Use absolute error instead of average error for path check --- babl/babl-fish-path.c | 6 +++--- babl/babl-util.c | 25 ++++++++++++++++++++++--- babl/babl-util.h | 11 ++++++++--- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c index ebf2cb5..82838e9 100644 --- a/babl/babl-fish-path.c +++ b/babl/babl-fish-path.c @@ -708,9 +708,9 @@ get_path_instrumentation (FishPathInstrumentation *fpi, babl_process (fpi->fish_destination_to_rgba, fpi->destination, fpi->destination_rgba_double, NUM_TEST_PIXELS); - *path_error = babl_rel_avg_error (fpi->destination_rgba_double, - fpi->ref_destination_rgba_double, - NUM_TEST_PIXELS * 4); + *path_error = babl_abs_error (fpi->destination_rgba_double, + fpi->ref_destination_rgba_double, + NUM_TEST_PIXELS * 4); #if 0 fpi->fish_rgba_to_source->fish.processings--; diff --git a/babl/babl-util.c b/babl/babl-util.c index 92977ac..f99b54b 100644 --- a/babl/babl-util.c +++ b/babl/babl-util.c @@ -88,9 +88,28 @@ babl_process_cost (long ticks_start, } double -babl_rel_avg_error (double *imgA, - double *imgB, - long samples) +babl_abs_error (const double *imgA, + const double *imgB, + long samples) +{ + double abs_error = 0.0; + long i; + + for (i = 0; i < samples; i++) + { + double sample_error = fabs (imgA[i] - imgB[i]); + + if (sample_error > abs_error) + abs_error = sample_error; + } + + return abs_error; +} + +double +babl_rel_avg_error (const double *imgA, + const double *imgB, + long samples) { double error = 0.0; long i; diff --git a/babl/babl-util.h b/babl/babl-util.h index bdaeec8..8c49619 100644 --- a/babl/babl-util.h +++ b/babl/babl-util.h @@ -27,7 +27,12 @@ babl_process_cost (long ticks_start, long ticks_end); double -babl_rel_avg_error (double *imgA, - double *imgB, - long samples); +babl_rel_avg_error (const double *imgA, + const double *imgB, + long samples); + +double +babl_abs_error (const double *imgA, + const double *imgB, + long samples); #endif -- 2.30.2